<?php
require_once("sys_conf.inc");
if (isset($_POST["poll"]))
{
	$poll = $_POST["poll"];
	$link_id = mysql_connect($DBHOST,$DBUSER,$DBPWD);
	mysql_select_db($DBNAME);
	mysql_query("SET NAMES 'utf8'");
	$id = $poll["id"];
	$subject = strip_tags($poll["subject"]);
	$startTime = $poll["startTime"];
	$endTime = $poll["endTime"];
	$pollType = $poll["pollType"];
	$description = strip_tags($poll["description"]);
	$creator = '1';
	if(!$id){
		$createTime = date("Y-m-d H:i:s");
		$sql = "insert into extpollsubject(subject,startTime,endTime,pollType,description,creator,createTime,modifyTime) values('$subject','$startTime','$endTime','$pollType','$description','$creator','$createTime','$createTime')";
		mysql_query($sql);
		echo "<script>alert('添加成功!');location='../poll_list.php';</script>";
	}else{
		$modifyTime = date("Y-m-d H:i:s");
		$sql = "UPDATE extpollsubject SET subject = '$subject',startTime = '$startTime', endTime = '$endTime', pollType = '$pollType', description = '$description', modifyTime = '$modifyTime'  WHERE id = '$id'";
		mysql_query($sql);
		echo "<script>alert('修改成功!');location='../poll_list.php';</script>";
	}
}
?>
